<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>history对象</title>
</head>

<body>
    <a href="www.baidu.com">百度</a>
    <button>前进</button>
    <button>后退</button>
    <script>
        // 相当于浏览器的前进后退按钮
        var btn = document.querySelectorAll('button')
        btn[0].addEventListener('click', function () {
            // 页面前进
            // history.forward()
            // 前进一步 数字是多少就前进或后退多少步
            history.go(1)
        })
        btn[1].addEventListener('click', function () {
            // 页面后退
            history.back()
            // 后退一步
            history.go(-1)
        })
    </script>
</body>

</html>